#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
const int N=3e5+5;
int a[2][N],dis[2][N],dis2[2][N],dis3[2][N];
signed main(){
int n=read();
for(int i=0;i<2;++i){
for(int j=1;j<=n;++j){
a[i][j]=read();
}
}
for(int i=1;i<=n;++i){
for(int j=0;j<2;++j){
dis[j][i]=dis[j][i-1]+((i%2)==j)*(a[1-j][i-1]*((i-1)*2-((i-1)%2!=1-j)-1)+a[1-j][i]*(i*2-(i%2!=1-j)-1))+a[j][i]*(2*i-(i%2!=j)-1);
}
}
int mx=max(dis[0][n],dis[1][n]);
int k=0;
for(int i=0;i<2;++i){
for(int j=n;j>0;--j){
dis2[i][j]=dis2[i][j+1]+a[i][j]*(j-1);
dis3[i][j]=dis3[i][j+1]+a[i][j];
}
}
for(int i=1;i<n;++i){
int sum=dis[1-i%2][i-1];
int sum2=dis2[1-i%2][i]+(i-1)*dis3[1-i%2][i];
int sum3=(2*n-2+i)*dis3[i%2][i]-dis2[i%2][i];
mx=max(mx,sum+sum2+sum3);
}
printf("%lld\n",mx);
return 0;
}
492A - Vanya and Cubes | 217A - Ice Skating |
270A - Fancy Fence | 181A - Series of Crimes |
1638A - Reverse | 1654C - Alice and the Cake |
369A - Valera and Plates | 1626A - Equidistant Letters |
977D - Divide by three multiply by two | 1654B - Prefix Removals |
1654A - Maximum Cake Tastiness | 1649A - Game |
139A - Petr and Book | 1612A - Distance |
520A - Pangram | 124A - The number of positions |
1041A - Heist | 901A - Hashing Trees |
1283A - Minutes Before the New Year | 1654D - Potion Brewing Class |
1107B - Digital root | 25A - IQ test |
785A - Anton and Polyhedrons | 1542B - Plus and Multiply |
306A - Candies | 1651C - Fault-tolerant Network |
870A - Search for Pretty Integers | 1174A - Ehab Fails to Be Thanos |
1169A - Circle Metro | 780C - Andryusha and Colored Balloons |